package com.zephyr.vchcenter.bpm.decision;

import org.apache.log4j.Logger;

import com.hiaward.bpm.context.ServiceContext;
import com.hiaward.bpm.exception.ParameterException;
import com.hiaward.bpm.exception.RuleException;
import com.hiaward.bpm.exception.ServiceException;
import com.hiaward.bpm.rule.Decision;
import com.zephyr.vchcenter.bean.Voucher;
import com.zephyr.vchcenter.bpm.action.LocalScanAuditAction;
import com.zephyr.vchcenter.dao.IBaseDao;
import com.zephyr.vchcenter.helper.SpringHelper;

public class IdExpDecisionHandler extends Decision {
	private final Logger log=Logger.getLogger(IdExpDecisionHandler.class);
	@Override
	public void exceptionHandle(ServiceContext arg0) {
		

	}

	@Override
	public String make(ServiceContext context) throws RuleException,
			ServiceException, ParameterException {
		log.debug("����IdExpDecisionHandler进入IdExpDecisionHandler...................");
		String vchsid=(String)context.getInputParameterValue("vchsid");
		IBaseDao dao=(IBaseDao)SpringHelper.getBean("baseDao");
	    Voucher voucher=(Voucher)dao.findById("Voucher", vchsid);
		String idstate=voucher.getIdstate();
		String idresult=voucher.getIdresult();
		String chkres=voucher.getChkres();
		String transition=null;
		if("6".equals(idstate)){
			transition="to localScan";
		}else{
			if("2".equals(idresult)&&"2".equals(chkres)){
				voucher.setTallytype("1");
				transition="to tally";
			}else{
				voucher.setTallytype("2");
				transition="to refuse";
			}
			
		}
		dao.saveOrUpdate(voucher);
		log.debug("�liIdExpDecisionHandlerl离开IdExpDecisionHandler..................");
		return transition;
	}

}
